package com.it.you.base.date;

import cn.hutool.core.date.DateUtil;
import com.it.you.common.utils.DateValidUtil;
import com.it.you.pojo.Worker;
import org.thymeleaf.util.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;

public class DateTest1 {

    public static void main(String[] args) {
        String time = "20230202";
        Date date = DateUtil.parse(time);
        //获取指定日期当天的结尾时间
        System.out.println(DateUtil.endOfDay(date));
        //获取指定日期当天的开始时间
        System.out.println(DateUtil.beginOfDay(date));
        //获取昨天
        System.out.println(DateUtil.format(DateUtil.yesterday(), "yyyyMMdd"));
        //获取指定时间的month
        System.out.println(DateUtil.month(DateUtil.parse("20231201")) + 1);

        //时间格式化
        String msg = new SimpleDateFormat("预计yyyy年MM月dd日到货").format(date);
        System.out.println(msg);

    }
}
